package psbc.daily.controller;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import psbc.daily.dao.mapper.MyLogMapper;
import psbc.daily.dao.model.MyLog;

import java.util.List;

/**
 * @author jlwang
 * @version 1.0.0
 * @Description TODO
 * @ClassName MyLogController.java
 * @createTime 2021年08月12日 10:24:00
 */
@RequestMapping("/mylog")
@RestController("")
public class MyLogController {
    @Autowired
    private MyLogMapper myLogMapper;

    @PostMapping("/add")
    public int addRecord(@RequestBody MyLog record) {
        return myLogMapper.insertSelective(record);
    }

    @PostMapping("/selectById")
    public MyLog selectById(@RequestBody int id) {
        return myLogMapper.selectById(id);
    }

    @GetMapping("/selectAll")
    public List<MyLog> selectAll() {
        return myLogMapper.selectAll();
    }

    @PostMapping("/selectByDate")
    public List<MyLog> selectByDate(@RequestBody String recordDate) {
        System.out.println(recordDate);

        List<MyLog> myLogs = myLogMapper.selectByDate(recordDate);
        System.out.println(myLogs);
        return myLogs;
    }

    @PostMapping("/deleteByDate")
    public int deleteByDate(@RequestBody String recordDate) {
        return myLogMapper.deleteByDate(recordDate);
    }

    @PostMapping("/deleteById")
    public int deleteById(@RequestBody int id) {
        return myLogMapper.deleteById(id);
    }

    @PostMapping("/updateRecord")
    public int updateRecord(@RequestBody MyLog myLog) {
        return myLogMapper.updateSelective(myLog);
    }
}
